

use "${pathdata_robustness}/RobustnessExperiment4.dta", clear

/*
Treatments
1. Story | Beliefs: Count
2. Story | Beliefs: %
3. Stat  | Beliefs: Count | Info: Count
4. Stat  | Beliefs: Count | Info: %
5. Stat  | Beliefs: Count | Info: Count
6. Stat  | Beliefs: Count |	Info: %


*/



* ########## REGRESSIONS ##########

	gen type = 1 if beliefs_type == "count" & inlist(condition, "storyshort_pos", "storyshort_neg") // Dissimilar Format
	replace type = 2 if beliefs_type == "percentage" & inlist(condition, "storyshort_pos", "storyshort_neg") // Similar Format
	replace type = 3 if beliefs_type == "count" & statistics_type == "count" & inlist(condition, "statistic_neg", "statistic_pos") // Dissimilar Format / Statistic Dissimilar 
	replace type = 4 if beliefs_type == "count" & statistics_type == "percentage" & inlist(condition, "statistic_neg", "statistic_pos") // Dissimilar Format / Statistic Similar
	replace type = 5 if beliefs_type == "percentage" & statistics_type == "count" & inlist(condition, "statistic_neg", "statistic_pos")  // Similar Format / Statistic Dissimilar
	replace type = 6 if beliefs_type == "percentage" & statistics_type == "percentage" & inlist(condition, "statistic_neg", "statistic_pos")  // Similar Format / Statistic Similar
	
	
	tab condition_
	
	
	
	gen info_percent = .
	replace info_percent = 0 if inlist(type, 1,2,3,5)
	replace info_percent = 1 if inlist(type, 4,6)
	
	gen belief_percent = .
	replace belief_percent = 0 if inlist(type,1,3,4)
	replace belief_percent = 1 if inlist(type,2,5,6)
	
	gen stats = .
	replace stats = 0 if inlist(type,1,2)
	replace stats = 1 if inlist(type,3,4,5,6)


preserve
	/* Regression Belief Impact delay product */

	
	keep prolific_pid product effect effect_recall combined_recall type info_percent belief_percent stats

	rename effect dev0
	rename effect_recall dev1
	
	gen info_percentXbelief_percent = 0
	replace info_percentXbelief_percent = 1 if  info_percent == 1 & belief_percent == 1
	
	*Column (3): STORY TREATMENT ONLY - Correct recall on product indicators
	eststo reg3: reg combined_recall belief_percent if stats == 0, cluster(prolific_pid)
	estadd scalar x = _b[_cons]
	
	*Column (4): STATISTIC TREATMENT ONLY - Correct recall on product indicators
	eststo reg4: reg combined_recall info_percent belief_percent info_percentXbelief_percent if stats == 1, cluster(prolific_pid)
	estadd scalar x = _b[_cons]
	

	reshape long dev, i(prolific_pid product) j(delay) // Make the data long as we want to pool Immediate and Delay

	* Interaction Terms
	gen delayXbelief_percent = 0
	replace delayXbelief_percent = 1 if delay == 1 & belief_percent == 1

	gen delayXinfo_percent = 0
	replace delayXinfo_percent = 1 if delay == 1 & info_percent == 1
	
	gen delayXinfoXbelief = 0
	replace delayXinfoXbelief = 1 if delay == 1 & info_percent == 1 & belief_percent == 1

	*Column (1): STORY TREATMENT ONLY - Belief Impact on indicators - LONG DATASET
	eststo reg1: reg dev delay belief_percent delayXbelief_percent if stats == 0, cluster(prolific_pid)
	estadd scalar x = _b[_cons] // Here, we store the constant to put it into the footer :) 

	*Column (2): STATISTIC TREATMENT ONLY - Belief Impact on indicators - LONG DATASET
	eststo reg2: reg dev delay info_percent delayXinfo_percent  belief_percent delayXbelief_percent info_percentXbelief_percent delayXinfoXbelief if stats == 1, cluster(prolific_pid)
	estadd scalar x = _b[_cons]

restore


	
	
	esttab reg1 reg2 reg3 reg4 using "${pathout_robustness}//tables/tableA4.tex", ///
		booktabs nonotes replace compress label nomtitles star(* 0.10 ** 0.05 *** 0.01) ///
		keep(delay info_percent belief_percent delayXinfo_percent delayXbelief_percent info_percentXbelief_percent delayXinfoXbelief) order( belief_percent delayXbelief_percent info_percent delayXinfo_percent info_percentXbelief_percent delayXinfoXbelief  delay) coeflabels(delay "Delay" belief_percent "Similar Format" delayXbelief_percent "Delay $/times$ Similar Format" info_percent "Statistic Similar" info_percentXbelief_percent "Statistic Similar $/times$ Similar Format" delayXinfo_percent "Delay $/times$ Statistic Similar" delayXinfoXbelief "Delay $/times$ Statistic Similar $/times$ Similar Format") ///
		se(2) b(a2) stats(x N r2, fmt(2 0 2) label("Control Mean" "Observations" "R^2"))  ///
		prehead("{\begin{tabular}{l*{4}{c}}\toprule\toprule&\multicolumn{4}{c}{\textit{Dependent variable:}}//[.1cm] &\multicolumn{2}{c}{Belief Impact} &  \multicolumn{2}{c}{Combined Recall} //\cmidrule(lr){2-3} \cmidrule(lr){4-5} // \textit{Sample:} &\multicolumn{1}{c}{Story} &\multicolumn{1}{c}{Stat} &\multicolumn{1}{c}{Story} &\multicolumn{1}{c}{Stat} //")
